﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace WebLogin
{
    public class DbHelper
    {
        #region 连接字符串
        private static readonly string conString = "server = .; database =InSaleSave; uid =sa; pwd =cultural0725.";
        #endregion

        #region 数据库数据获取
        public static DataTable GetDataTable(string sql)
        {
            SqlDataAdapter dataAdapter = new SqlDataAdapter(sql,conString);

            DataTable dataTable = new DataTable();

            dataAdapter.Fill(dataTable);

            return dataTable;
        }
        #endregion

        #region 数据增加、更新与删除
        public static int AddOrUpdateOrDelete(string sql)
        {
            SqlConnection connection = new SqlConnection(conString);
            SqlCommand command = new SqlCommand(sql,connection);
            connection.Open();
            var qy = command.ExecuteNonQuery();
            connection.Close();
            return qy;
        }
        #endregion

    }
}